Question: 1 -
Which is a valid keyword in java?
-
Float
-
unsigned
-
interface
-
string
Answer:
interface
Solution not available.
Question: 2 -
Which one of these lists contains only Java programming language keywords?
-
try, virtual, throw, final, volatile, transient
-
goto, instanceof, native, finally, default, throws
-
class, if, void, long, Int, continue
-
byte, break, assert, switch, include
Answer:
goto, instanceof, native, finally, default, throws
Solution:
All the words in option "goto, instanceof, native, finally, default, throws" are among the 49 Java keywords. Although goto reserved as a keyword in Java, goto is not used and has no function.
Option "class, if, void, long, Int, continue" is wrong because the keyword for the primitive int starts with a lowercase i.
Option "try, virtual, throw, final, volatile, transient" is wrong because "virtual" is a keyword in C++, but not Java.
Option "byte, break, assert, switch, include" is wrong because "include" is a keyword in C, but not in Java.
All the words in option "goto, instanceof, native, finally, default, throws" are among the 49 Java keywords. Although goto reserved as a keyword in Java, goto is not used and has no function.
Option "class, if, void, long, Int, continue" is wrong because the keyword for the primitive int starts with a lowercase i.
Option "try, virtual, throw, final, volatile, transient" is wrong because "virtual" is a keyword in C++, but not Java.
Option "byte, break, assert, switch, include" is wrong because "include" is a keyword in C, but not in Java.
Question: 3 -
Which four options describe the correct default values for array elements of the types indicated?
-
1, 2, 3, 4
-
1, 3, 4, 5
-
2, 4, 5, 6
-
3, 4, 5, 6
Answer:
1, 3, 4, 5
Solution:
(1), (3), (4), (5) are the correct statements.
(2) is wrong because the default value for a String (and any other object reference) is null, with no quotes.
(6) is wrong because the default value for boolean elements is false.
(1), (3), (4), (5) are the correct statements.
(2) is wrong because the default value for a String (and any other object reference) is null, with no quotes.
(6) is wrong because the default value for boolean elements is false.
Question: 4 -
Which is a reserved word in the Java programming language?
-
native
-
array
-
subclasses
-
method
Answer:
native
Solution:
The word "native" is a valid keyword, used to modify a method declaration.
The word "native" is a valid keyword, used to modify a method declaration.
Question: 5 -
Which will legally declare, construct, and initialize an array?
-
int myList [] = {4, 3, 7};
-
int [] myList = (5, 8, 2)
-
int myList [] [] = {4,9,7,0};
-
int [] myList = {"1", "2", "3"};
Answer:
int myList [] = {4, 3, 7};